package cn.jxau.service.impl;

import java.util.ArrayList;
import java.util.List;

import org.springframework.stereotype.Service;

import cn.jxau.bean.po.ArticleComment;
import cn.jxau.bean.po.Reply;
import cn.jxau.service.replyService;

@Service
public class ReplyServiceImpl extends AbstractCommonService implements replyService{
	@Override
	public List<Reply> getFirstReply(List<ArticleComment> comments) {
		List<Reply> list = new ArrayList<Reply>();
		for (ArticleComment comment : comments) {
			list.add(replyMapper.getFirstReply(comment.getId()));
		}
		return list;
	}

	@Override
	public int insertReply(Reply reply) {
		return replyMapper.insert(reply);
	}

	@Override
	public List<Reply> getOneAllOtherFirstReply(List<ArticleComment> comments,Long pid) {
		List<Reply> list = new ArrayList<Reply>();
		List<Reply> other = replyMapper.getOneAllOther(pid);
		for (ArticleComment comment : comments) {
			if(comment.getId()!=pid){
				list.add(replyMapper.getFirstReply(comment.getId()));
			}
		}
		list.addAll(other);
		System.out.println(list);
		return list;
	}
}













